package com.wry.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <h1>  <h1>
 *
 * @author wry
 * @since 2023/8/21 11:13
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "order")
@Setting(settingPath = "classpath:es/elasticsearch_setting.json")
@Mapping(mappingPath = "classpath:es/elasticsearch_mapping.json")
public class Order implements Serializable {
    /**
     * type : 字段数据类型
     * analyzer : 分词器类型
     * index : 是否索引(默认:true)
     * Keyword : 短语,不进行分词
     */
    @Id
    private Integer id;

    @Field(type = FieldType.Keyword)
    private Long orderNo;

    @Field(type = FieldType.Integer)
    private Integer orderType;

    @Field(type = FieldType.Long)
    private Long orderAmount;

    @Field(type = FieldType.Text)
    private String orderDesc;

    @Field(type = FieldType.Text)
    private String username;

    @Field(type = FieldType.Keyword)
    private String userPhone;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Field(type = FieldType.Date,format = DateFormat.date_hour_minute_second_millis)
    private LocalDateTime createAt;

    private Map<String, List<String>> highlights;
}
